class Solution {
    public boolean lemonadeChange(int[] bills) {
        //<金额, 个数>
        int five = 0, ten = 0;
        if(bills[0] != 5) return false;
        for(int i = 0; i < bills.length; i++) {
            if(bills[i] == 5) five++;
            else if(bills[i] == 10) {
                if(five == 0) return false;
                five--; ten++;
            }else {
                if(five == 0) {
                    return false;
                }else if(ten != 0) {
                    //贪心
                    ten--;
                    five--;
                }else {
                    if(five < 3) return false;
                    five -= 3;
                }
            }
        }
        return true;
    }
}